package com.universalInterface.common.result;

/**
 * @author Lx
 * @date 2023/12/8 14:43
 * @description 提前定义项目所需要的状态码和状态码描述，方便使用
 * <br/> package org.springframework.http也提供一个有关状态码的HttpStatus类
 */
public enum ApiCode {

    /**
     * Http标准状态码
     */
    CONTINUE(100, "请继续发送请求的剩余部分"),
    SWITCHING_PROTOCOLS(101, "协议切换"),
    PROCESSING(102, "请求将继续执行"),
    CHECKPOINT(103,  "可以预加载"),

    OK(200,  "请求成功"),
    CREATED(201,  "请求已经成功处理，并创建了资源"),
    ACCEPTED(202,  "请求已经接受，等待执行"),
    NON_AUTHORITATIVE_INFORMATION(203,  "请求已经成功处理，但是信息不是原始的"),
    NO_CONTENT(204,  "请求已经成功处理，没有内容需要返回"),
    RESET_CONTENT(205, "请求已经成功处理，请重置视图"),
    PARTIAL_CONTENT(206, "部分Get请求已经成功处理"),
    MULTI_STATUS(207,  "请求已经成功处理，将返回XML消息体"),
    ALREADY_REPORTED(208, "请求已经成功处理，一个DAV的绑定成员被前一个请求枚举，并且没有被再一次包括"),
    IM_USED(226,  "请求已经成功处理，将响应一个或者多个实例"),

    MULTIPLE_CHOICES(300,  "提供可供选择的回馈"),
    MOVED_PERMANENTLY(301,  "请求的资源已经永久转移"),
    FOUND(302, "请重新发送请求"),
    // MOVED_TEMPORARILY(302, "Moved Temporarily", "") 已经过时
    SEE_OTHER(303,  "请以Get方式请求另一个URI"),
    NOT_MODIFIED(304, "资源未改变"),
    USE_PROXY(305,"请通过Location域中的代理进行访问"),
    // 306在新版本的规范中被弃用
    TEMPORARY_REDIRECT(307,  "请求的资源临时从不同的URI响应请求"),
    RESUME_INCOMPLETE(308, "请求的资源已经永久转移"),

    BAD_REQUEST(400,  "请求错误，请修正请求"),
    UNAUTHORIZED(401,  "没有被授权或者授权已经失效"),
    PAYMENT_REQUIRED(402,  "预留状态"),
    FORBIDDEN(403,  "请求被理解，但是拒绝执行"),
    NOT_FOUND(404,  "资源未找到"),
    METHOD_NOT_ALLOWED(405,  "请求方法不允许被执行"),
    NOT_ACCEPTABLE(406,  "请求的资源不满足请求者要求"),
    PROXY_AUTHENTICATION_REQUIRED(407,  "请通过代理进行身份验证"),
    REQUEST_TIMEOUT(408,  "请求超时"),
    CONFLICT(409,  "请求冲突"),
    GONE(410,  "请求的资源不可用"),
    LENGTH_REQUIRED(411,  "Content-Length未定义"),
    PRECONDITION_FAILED(412, "不满足请求的先决条件"),
    REQUEST_ENTITY_TOO_LARGE(413,  "请求发送的实体太大"),
    REQUEST_URI_TOO_LONG(414,  "请求的URI超长"),
    UNSUPPORTED_MEDIA_TYPE(415,  "请求发送的实体类型不受支持"),
    REQUESTED_RANGE_NOT_SATISFIABLE(416,  "Range指定的范围与当前资源可用范围不一致"),
    EXPECTATION_FAILED(417,  "请求头Expect中指定的预期内容无法被服务器满足"),
    // I_AM_A_TEAPOT(418, "I'm a teapot", ""), 该代码没有被服务器实现
    // INSUFFICIENT_SPACE_ON_RESOURCE(419, "Insufficient Space On Resource", ""),  已经过时
    // METHOD_FAILURE(420, "Method Failure", ""),  已经过时
    // DESTINATION_LOCKED(421, "Destination Locked", ""),  已经过时
    UNPROCESSABLE_ENTITY(422,  "请求格式正确，但是由于含有语义错误，无法响应"),
    LOCKED(423,  "当前资源被锁定"),
    FAILED_DEPENDENCY(424,  "由于之前的请求发生错误，导致当前请求失败"),
    UPGRADE_REQUIRED(426,  "客户端需要切换到TLS1.0"),
    PRECONDITION_REQUIRED(428,  "请求需要提供前置条件"),
    TOO_MANY_REQUESTS(429,  "请求过多"),
    REQUEST_HEADER_FIELDS_TOO_LARGE(431,  "请求头超大，拒绝请求"),

    INTERNAL_SERVER_ERROR(500,  "服务器内部错误"),
    NOT_IMPLEMENTED(501,  "服务器不支持当前请求的部分功能"),
    BAD_GATEWAY(502,  "响应无效"),
    SERVICE_UNAVAILABLE(503,  "服务器维护或者过载，拒绝服务"),
    GATEWAY_TIMEOUT(504,  "上游服务器超时"),
    HTTP_VERSION_NOT_SUPPORTED(505, "不支持的HTTP版本"),
    VARIANT_ALSO_NEGOTIATES(506,  "服务器内部配置错误"),
    INSUFFICIENT_STORAGE(507,  "服务器无法完成存储请求所需的内容"),
    LOOP_DETECTED(508,  "服务器处理请求时发现死循环"),
    BANDWIDTH_LIMIT_EXCEEDED(509,  "服务器达到带宽限制"),
    NOT_EXTENDED(510,  "获取资源所需的策略没有被满足"),
    NETWORK_AUTHENTICATION_REQUIRED(511,  "需要进行网络授权"),


    /**
     * 项目自定义状态码
     **/
    USER_NOT＿EXIST(4000, "用户不存在"),
    USER_NOT＿REGISTERED(4001, "用户尚未注册"),
    PASSWORD_ERROR(4002, "密码错误"),
    ENTERED_PASSWORD_DIFFER(4003, "两次输入的密码不一致"),
    PASSWORD_UNCHANGED(4004, "新密码和旧密码不能一致"),
    SUCCESSFULLY_MODIFY_PASSWORD(4005, "成功修改密码"),
    //invalid access token,please check
    INVALID_TOKEN(4006, "访问令牌无效，请检查"),
    ACCESS_TOKEN_EXPIRED(4006, "访问令牌已过期"),
    //Invalid refresh token
    INVALID_REFRESH_TOKEN(4007, "无效的刷新令牌"),
    //Invalid authorization code
    INVALID_AUTHORIZATION_CODE(4008, "无效的授权代码"),
    MOBILE_CODE(4009, "无效的授权代码"),
    MOBILE_NO_FOUND(4009, "无效的授权代码"),
    LOGIN_EXCEPTION(4010, "登录失败"),
    VERIFICATION_CODE_ERROR(4011, "验证码错误"),
    USER_ID_DISABLED(4013, "用户已禁用，请联系管理员"),
    USER_ID_LOCKED(4014, "用户已被锁定，请联系管理员"),
    ACCOUNT_EXCEPTION(4014, "账号已登录，请修改密码"),
    USER_EXIST(4015, "用户已存在"),


    PARAMETER_EXCEPTION(5001, "请求参数校验异常"),
    PARAMETER_PARSE_EXCEPTION(5002, "请求参数解析异常"),
    METHOD_ARGUMENT_TYPE_MISMATCH_EXCEPTION(5003, "方法参数类型不匹配异常"),
    HTTP_MESSAGE_CONVERSION_EXCEPTION(5004, "json序列化异常"),


    HTTP_REPEAT_SUBMIT(5031, "请勿频繁提交请求"),
    DAO_EXCEPTION(5102, "数据库处理异常"),
    VERIFICATION_CODE_EXCEPTION(5103, "验证码校验异常"),
    TOKEN_EXCEPTION(5107, "Token解析异常"),

    MULTIPART_FILE_MAX_SIZE("上传文件超出大小"),
    MULTIPART_FILE_NOT_FOUND("未找到文件内容"),
    MULTIPART_FILE_TYPE_ERROR("上传文件不符合格式要求,按要求上出文件"),

    ;

    /**
     * 状态码code
     */
    private int code;
    /**
     * 状态码中文描述
     */
    private String message;

    ApiCode(String message) {
        this.message = message;
        this.code = 500;
    }

    ApiCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }

}